<?php

use think\migration\Migrator;
use think\migration\db\Column;

class CreateTableDraw extends Migrator
{
    public function up()
    {
        if (!$this->hasTable('draw')) {
            $table = $this->table('draw', ['engine' => 'MyISAM'])
                ->setId('id')
                ->setPrimaryKey('id')
                ->setComment('抽签表');
            $table->addColumn('name', 'string', ['limit' => 100, 'null' => false, 'comment' => '签名'])
                ->addColumn('luck', 'string', ['limit' => 100, 'null' => false, 'default' => '', 'comment' => '吉凶'])
                ->addColumn('poetry', 'string', ['limit' => 500, 'null' => false, 'default' => '', 'comment' => '签诗'])
                ->addColumn('open_poetry', 'string', ['limit' => 500, 'null' => false, 'default' => '', 'comment' => '解签'])
                ->create();
        }
    }

    public function down()
    {
        if ($this->hasTable('draw')) {
            $this->dropTable('draw');
        }
    }
}
